# -*- coding: utf-8 -*-
"""
-------------------------------------------------
   File Name：     setting.py
   Description :   配置文件
   Author :        William
   date：          2020/2/19
-------------------------------------------------
   Change Activity:
                   2020/2/19: 文件初创
-------------------------------------------------
"""
import os,redis
from loguru import logger
import traceback

BASE_DIR = os.path.dirname(os.path.abspath(__file__))

#日志配置项
LOG_DIR = os.path.join(BASE_DIR, "../log")
if not os.path.exists(LOG_DIR):
    try:
        os.makedirs(LOG_DIR)
    except:
        traceback.print_exc()
logger.add(os.path.join(LOG_DIR,"{time:YYYY-MM-DD}.log"),
           format="{time:YYYY-MM-DD at HH:mm:ss} - {level} - {message}",
           rotation="00:00",
           enqueue=True)

""" 数据库配置 """
DB_TYPE = os.getenv('db_type', 'REDIS')
DB_HOST = os.getenv('db_host', '127.0.0.1')
DB_PORT = os.getenv('db_port', 6379)
DB_PASSWORD = os.getenv('db_password', '')
PROXY_NAME = "Proxy"
Pool = redis.ConnectionPool(host=DB_HOST,
                            port=6379,
                            password=DB_PASSWORD,
                            max_connections=20)

# 爬虫代理项
PROXY_GETTER = [
    "zhandaye",
]

"""
Web 服务配置项 
API config http://127.0.0.1:6010 
"""
SERVER_API = {
    "HOST": "0.0.0.0",
    "PORT": 6010,
    "token":"123456." #用于web访问安全
}

#代理ip用户认证密码加密，key 和偏移量
KEY_STR = "123456."
IV_B = "123456."

